package com.gbq.qimo.mapper.impl;

import com.gbq.qimo.mapper.AdminMapper;
import com.gbq.qimo.pojo.Admin;
import com.gbq.qimo.utils.JDBCUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @ClassName AdminMapperImpl
 * @Description TODO
 * @Author guobenqi
 * @Date 2021/5/29 16:00
 */
public class AdminMapperImpl implements AdminMapper {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public Admin findOneAdmin(String username, String password) {
        try{
//            System.out.println(username);
//            System.out.println(password);
            String sql = "select * from admin where username = ? and password = ?";
            Admin admin = template.queryForObject(sql, new BeanPropertyRowMapper<Admin>(Admin.class), username, password);
            return admin;
        }catch (Exception e){
            e.printStackTrace();

        }
       return null;
    }
}
